<?php

namespace App\Http\Resources\Mini\AnnouncementResource;

use Illuminate\Http\Resources\Json\ResourceCollection;

class AnnouncementClassCollection extends ResourceCollection
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'data'         => $this->collection->map(function ($item) {
                return [
                    'id'         => $item->id,
                    'name'       => $item->name,
                    'ename'      => $item->ename,
                    "author"=>$item->one_user->username,
                    "content"=>$item->content,
                    'created_at' => $item->created_at->format('Y-m-d H:i:s'),
                    'updated_at' => $item->updated_at->format('Y-m-d H:i:s'),
                ];
            }),
        ];
    }
}
